@using BlazorApp.Pages.Common.Html
@using BlazorApp.Pages.Common.Html.HTable
@using BlazorApp.Pages.Common.Metadata
@using BlazorApp.Pages.Event
@using k8s.Models
@using Mapster
@inherits BlazorApp.Pages.Common.DrawerPageBase<k8s.Models.V1ClusterRoleBinding>
@if (ClusterRoleBinding != null)
{
    <ClusterRoleBindingAction Item="ClusterRoleBinding" MenuMode="MenuMode.Horizontal"></ClusterRoleBindingAction>
    <Divider Orientation="left" Style="font-weight:bold">@L["Metadata"]</Divider>
    <MetadataView Item="ClusterRoleBinding.Metadata" ExplainFieldPrefix="clusterRoleBinding"></MetadataView>
    <Divider Orientation="left" Style="font-weight:bold">@L["Spec"]</Divider>
    <HTable Bordered Column="1">

        @if (ClusterRoleBinding.RoleRef is not null)
        {
            <HTableColumn Title=@L["ClusterRole"] ExplainField="clusterRoleBinding.roleRef">
                <RefView Ref="@(ClusterRoleBinding.RoleRef.Adapt<V1ObjectReference>())" FullView="true"></RefView>
            </HTableColumn>
        }
        @if (ClusterRoleBinding.Subjects is { Count: > 0 })
        {
            <HTableColumn Title=@L["Subjects"] ExplainField="clusterRoleBinding.subjects">
                @foreach (var subject in ClusterRoleBinding.Subjects)
                {
                    <RefView Ref="@(subject.Adapt<V1ObjectReference>())" FullView="true"></RefView>
                }
            </HTableColumn>
        }
    </HTable>
    <MiniEventListView Uid="@ClusterRoleBinding.Metadata.Uid"></MiniEventListView>
}
